package com.shujia.homework;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class MyMapper extends Mapper<LongWritable, Text, Text, LongWritable> {
    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text,Text , LongWritable>.Context context) throws IOException, InterruptedException {
        String line = value.toString();
        String[] splits = line.split("\t");
        if (line.length()<100) {
            context.write(new Text(splits[0]),new LongWritable(-1L));
        }else {
            context.write(new Text(splits[0]+"-"+splits[2]),new LongWritable(Long.parseLong(splits[4])));
        }
    }
}
